package com.goldgov.column.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.goldgov.column.dao.ColumnDao;
import com.goldgov.column.service.Column;
import com.goldgov.column.service.ColumnQuery;
import com.goldgov.column.service.ColumnService;
import com.goldgov.column.service.UserColumn;
import com.goldgov.column.service.UserColumnQuery;

@Service
public class ColumnServiceImpl implements ColumnService {
	
	@Autowired
	private ColumnDao columnDao;

	@Override
	public void upDateUserColumn(ColumnQuery query) {
		//if(query.getSearchDelColumnIds()!=null) {
			columnDao.delUserColumn(query);
		//}
//		List<UserColumn> list = columnDao.findUserColumn(query);
		if(query.getSearchAddColumnIds()!=null) {
			Integer[] columnIds = query.getSearchAddColumnIds();
			for (Integer columnId : columnIds) {
				UserColumn uc = new UserColumn();
				uc.setUserId(query.getSearchUserID());
				uc.setColumnId(columnId);
				uc.setType(query.getSearchType());
				columnDao.addUserColumn(uc);
			}
		}
	}

	@Override
	public List<UserColumn> findUserColumn(UserColumnQuery userColumnQuery) {
		return columnDao.findUserColumn(userColumnQuery);
	}
	
	@Override
	public List<Column> getLikeByUser(ColumnQuery query) {
		return columnDao.getLikeByUser(query);
	}
	@Override
	public List<Column> statisticsFwl(ColumnQuery query) {
		query.setPageSize(-1);
		return columnDao.statisticsFwl(query);
	}

	@Override
	public void deleteUserColumn(ColumnQuery query) {
		columnDao.delUserColumn(query);
	}

}
